<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
		<link rel="shortcut icon" href="../favicon.ico" /> 
		<link rel="stylesheet" type="text/css" href="../assets/admin/skins/default/style.css" />
		<script type="text/javascript" th:src="@{../assets/scripts/jquery/jquery-1.11.2.min.js}" ></script>
		
		<style>
			.login-form .col .icon.vcode {background-position: -112px -55px;}
			.login-form .col .vimage{position: absolute;display: block;top: 19px;left: 200px;background: url(../assets/admin/skins/default/skin_icons.png) no-repeat;cursor: pointer;}
			
			.one{
				
				width:50px;
				height:30px;
				background-color:green;
				position:absolute;
				left:230px;
				top:15px;
			}
		
		</style>
		
		
	</head>
	<body class="loginbody">
		<form id="loginForm" method="post">
			<!-- <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" /> -->
			<div style="width: 100%; height: 100%; min-width: 300px; min-height: 260px;"></div>
			<div class="login-wrap">
				<div class="login-logo">LOGO</div>
				<div class="login-form">
					<div class="col">
						<input name="mobile" type="text" id="mobile" onblur="checkMobile()" class="login-input" placeholder="请输入手机号" title="请输入手机号" /> 
						<label class="icon user" for="mobile"></label>
					</div>
					
					<div class="col">
						<input name="code" type="text" id="code" onblur="checkCode()" class="login-input" placeholder="请输入验证码" title="请输入验证码" />
						<label class="icon pwd" for="code"></label>
						<button class="one" type="button" id="btn" onclick="aaa()">获取</button>
					</div>
					
					<div class="col">
						<input name="password" type="password" id="password" class="login-input" placeholder="请输入密码" title="请输入密码" /> 
						<label class="icon pwd" for="password"></label>
					</div>
					
					<div class="col">
						<input name="password" type="password" id="password1" class="login-input" onblur="checkCPW(this,this)" placeholder="请输入确认密码" title="请输入确认密码" /> 
						<label class="icon pwd" for="password"></label>
					</div>
					
					<div class="col">
						<input type="submit" value="修改密码" class="login-btn" onclick="return check()" />
						<br/>
						<input type="submit" value="返回登录" class="login-btn" />
					</div> 
				</div>
				<!-- <div class="login-tips">
					<i></i>
					<p id="msgtip" th:text="${param.error!=null}?'验证码或者密码错误':'请输入用户名和密码'">请输入用户名和密码</p>
				</div> -->
			</div>
			<div class="copy-right">
				<p>版权所有 广州小马信息科技有限公司 Copyright © 2016 - 2017 sharemarking.com Inc. All Rights Reserved.</p>
			</div>
		</form>
		<script type="text/javascript">
		
		//验证手机号是否存在
		function checkMobile(){
			var mobile= document.getElementById("mobile").value;
			
			$.ajax({
				type:"post",
				url:"http://183.26.234.79:8080/tpl/pwd/checkMobile",
				data:{'mobile': mobile},
				dataType:"json",
				async:true,
				
				success:function(data){
					console.log("data:"+data);
					var sure=JSON.stringify(data);
					if(sure=="true"){
					//	confirm("手机号存在");
					}else{
						confirm("手机号不存在,请重新填写!");
 					} 
				}
				
			});
		}
		 
		//ajax发送验证码
		function aaa(){
			
			var mobile= document.getElementById("mobile").value;
			console.log("mobile:"+mobile);
			
			  if(mobile==null||mobile==""){
				confirm("手机号不能为空,请重新填写!");
				return false;
			}else{
				
				$.ajax({
					type:"post",
					url:"http://183.26.234.79:8080/tpl/pwd/rePassword",
					data:{'mobile': mobile},
					dataType:"json",
					
					success:function(data){
						confirm("验证码发送成功!");
	 					var phoneNum=data;
	 					console.log("phoneNum:"+phoneNum);
	 					if(phoneNum!=null){
	 						$('#btn').attr('disabled',"true",'background',"gray");//添加disabled属性 
	 						//$("#btn").css({ color: "#fff"});
	 					}
					}
				});
			}
		}
		
		//验证验证码是否正确
		function checkCode(){
			var code= document.getElementById("code").value;
			if(code==null||code==""){
				confirm("验证码不能为空,请重新填写!");
			}else{
				
				$.ajax({
					type:"post",
					url:"http://183.26.234.79:8080/tpl/pwd/checkCode",
					data:{'code':code},
					dataType:"json",
					
					success:function(data){
						console.log("验证码data:"+data);
						var sure=JSON.stringify(data);
						if(sure=="true"){
							
						}else{
							confirm("验证码错误或失效了,请重新填写!");
						}
					}
					
				});
			}
		}
		
		//验证前后密码必须一致
		function checkCPW(obj3,obj5){
			var password= document.getElementById("password").value;
			var password1= document.getElementById("password1").value;
			if(password!=password1){
				confirm("前后密码不一致,请重新填写!");
				return false;
			}else{
				return true;
			}
		}
		
		//验证表单信息  重设密码
		function check(){
			var mobile= document.getElementById("mobile").value;
			var code= document.getElementById("code").value;
			var password= document.getElementById("password").value;
			var password1= document.getElementById("password1").value;
			
			if(mobile==null||mobile==""||code==null||code==""||password==null||password==""||password1==null||password1==""){
				confirm("你的信息不够完善,请重新填写.");
	 			return false;
			}else{
				
				$.ajax({
					type:"post",
					url:"http://183.26.234.79:8080/tpl/pwd/resetPassword",
					data:{'password': password,'mobile':mobile},
					dataType:"json",
					
					success:function(data){
	 					//alert("发送成功");
					}
				});
			}
		}
		</script>
	</body>
</html>